module TrackChanges
   module Changes #:nodoc:

    protected

    def track_changes_get_changes
      @__model_changes = self.changes
    end

    def track_changes_save_audit
      return unless self.id && !@__model_changes.empty?

      user = current_user || TrackChanges::Configuration::get_default_user
      Audit.create_changes(self, @__model_changes, current_user)
    end
  end
end
